<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="cw" uri="/widget-tags"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	//模拟字典缓存
	java.util.Map dic = new java.util.HashMap();
	dic.put("dicSex", "[[1,'男'],[2,'女']]");
	application.setAttribute("dic", dic);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<cw:base />
		<script type="text/javascript">
			function getSexData() {
				return [ [ 1, '男' ], [ 2, '女' ] ];
			}
			
			function showImage(v,m,r) {
		 		return "<img src=<s:url value='/'/>" + v + "></img>";
		  	}
		</script>
	</head>
	<body>
		<ul>
			<li>
				<cw:fieldSet title="分组表格1" content="groupGrid1Div" collapsible="true" collapsed="false"/>
				<div id="groupGrid1Div">
					<cw:groupGrid id="groupGrid1" url="${pageContext.request.contextPath }/sample/grid/groupgrid.action" 
						groupField="industry" title="" exportable="false" forceFit="true" autoLoad="true">
						<cw:gridColumn property="company" width="30%" title="company" align="center"></cw:gridColumn>
						<cw:gridColumn property="price" width="20%" title="price" renderer="function(v){return Wonders.utils.Format.money(v,'￥')}" align="center"></cw:gridColumn>
						<cw:gridColumn property="change" width="20%" title="change" align="center"></cw:gridColumn>
						<cw:gridColumn property="industry" width="20%" title="industry" align="center"></cw:gridColumn>
					</cw:groupGrid>
				</div>
			</li>
		</ul>
		<hr>
		<ul>
			<li>
				<cw:fieldSet title="分组表格2" content="groupGrid2Div" collapsible="true" collapsed="false"></cw:fieldSet>
				<div id="groupGrid2Div">
					<cw:groupGrid id="groupGrid2" url="${pageContext.request.contextPath }/sample/grid/groupgrid.action" 
						groupField="industry" title="" exportable="true" forceFit="true"
						showGlobalStat="true" showGroupStat="true" summaryText="总计" subSummaryText="汇总" autoLoad="true">
						<cw:gridColumn property="company" width="30%" title="company" summaryType="count" align="center"></cw:gridColumn>
						<cw:gridColumn property="price" width="20%" title="price" renderer="function(v){return Wonders.utils.Format.money(v,'￥')}" summaryType="sum" align="center"></cw:gridColumn>
						<cw:gridColumn property="change" width="20%" title="change" summaryType="sum" summaryDecimalPrecision="1" align="center"></cw:gridColumn>
						<cw:gridColumn property="industry" width="20%" title="industry" align="center"></cw:gridColumn>
					</cw:groupGrid>
				</div>
			</li>
		</ul>
		<cw:theme></cw:theme>
		<script type="text/javascript">
			Ext.onReady(function(){
				var STORE1 = Ext.getCmp('groupGrid1').store;
				STORE1.on("load",function(s,r,o){
					resetHeight("groupGridFrame");
			    });
				
				var STORE2 = Ext.getCmp('groupGrid2').store;
				STORE2.on("load",function(s,r,o){
					resetHeight("groupGridFrame");
			    });
				resetHeight("groupGridFrame");
			})
		
			function resetHeight(frame) {
				var ifm = parent.document.getElementById(frame);
				var obj = document.body;
				var oStyle = obj.currentStyle? obj.currentStyle : window.getComputedStyle(obj, false);
				var initHeight = parseInt(document.body.clientHeight+parseInt(oStyle["margin-top"])+parseInt(oStyle["margin-bottom"]));
				ifm.height = parseInt(initHeight);
			}
		</script>
	</body>
</html>